<template>
  <div>
    <button @click="isShow=true">点击弹窗</button>
    <Teleport to="body">
      <div v-if="isShow" class="mask">
        <div class="dialog">
          <h1>我是一些内容</h1>
          <h1>一些内容</h1>
          <h1>一些内容</h1>
          <h1>一些内容</h1>
          <h1>一些内容</h1>
          <button @click="isShow=false">点击关闭</button>
        </div>
      </div>
    </Teleport>

  </div>
</template>

<script>
import { ref } from "vue";
export default {
  name: "Dialog",
  setup() {
    let isShow = ref(false);
    return {
      isShow
    };
  }
};
</script>

<style>

.mask {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.5);
}
.dialog {
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform:translate(-50%,-50%) ;
  width: 300px;
  height: 300px;
  background-color: green;
}

</style>